<template>
  <aside class="sidebar">
    <div class="sidebar-header">
      <h3>{{ title }}</h3>
    </div>
    <nav class="sidebar-nav">
      <div 
        v-for="item in items" 
        :key="item.type"
        class="sidebar-item"
        :class="{ active: currentType === item.type }"
        @click="$emit('select', item.type)"
      >
        <div class="item-content">
          <span class="icon">{{ item.icon }}</span>
          <span class="label">{{ item.label }}</span>
        </div>
      </div>
    </nav>
  </aside>
</template>

<script setup>
defineProps({
  title: {
    type: String,
    default: '分类导航'
  },
  items: {
    type: Array,
    required: true,
    // [{ type: 'bank', label: '银行流水', icon: '🏦' }]
  },
  currentType: {
    type: String,
    required: true
  }
})

defineEmits(['select'])
</script>

<style scoped>
.sidebar {
  width: 240px;
  height: 100%;
  background-color: white;
  border-right: 1px solid #e6e6e6;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 15px 20px;
  border-bottom: 1px solid #e6e6e6;
}

.sidebar-header h3 {
  margin: 0;
  color: #303133;
  font-size: 0.95rem;
}

.sidebar-nav {
  padding: 10px 0;
  flex: 1;
  overflow-y: auto;
}

.sidebar-item {
  padding: 14px 20px;
  cursor: pointer;
  color: #606266;
  border-left: 4px solid transparent;
  transition: all 0.2s;
  border-bottom: 1px solid #f0f0f0;
}

.sidebar-item:hover {
  color: #409eff;
}

.sidebar-item.active {
  color: #409eff;
  background: #ecf5ff;
  border-left-color: #409eff;
  font-weight: bold;
}

.item-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon {
  font-size: 1.1rem;
}

.label {
  font-size: 0.9rem;
}
</style>
